package com.dragon.repository.domain.vo;

import com.dragon.common.model.Update;
import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.Vendor;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@ApiModel(value = "")
public class VendorVO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    private Integer id;

    @ApiModelProperty(value = "供应商名称")
    private String name;

    @ApiModelProperty(value = "供应商电话")
    private String telephone;

    @ApiModelProperty(value = "供应商地址")
    private String address;

    @ApiModelProperty(value = "删除标识0未删除1删除")
    private Integer deleted;

    @ApiModelProperty(value = "供应商分类：1原材料 2零部件 3成品")
    private Integer vendorCategory;

    @ApiModelProperty(value = "信用评级")
    private Integer creditRating;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    @ApiModelProperty(value = "创建时间")
    private Date createTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    @ApiModelProperty(value = "修改时间")
    private Date updateTime;

    @ApiModelProperty(value = "供应商产品")
    private String vendorProduct;
    //private List<Product> productList;



    @NotNull(groups = Update.class,message = "主键不能为空")
    public static Vendor convert(VendorVO vo) {
        Vendor entity = new Vendor();
        BeanUtils.copyProperties(vo,entity);
        return entity;
    }
    public static List<Vendor> convertList(List<VendorVO> list) {
        List<Vendor> resultList = new ArrayList<>();
        for (VendorVO vo : list) {
            resultList.add(convert(vo));
        }
        return resultList;
    }
}
